<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: zzz
  Date: 2020/2/13
  Time: 21:29
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>家居家具后台管理系统</title>

    <!-- begin::global styles -->
    <link rel="stylesheet" href="${APP_PATH}/assets/vendors/bundle.css" type="text/css">
    <!-- end::global styles -->

    <link rel="stylesheet" href="${APP_PATH}/css/jigsaw.css">

    <!-- begin::custom styles -->
    <link rel="stylesheet" href="${APP_PATH}/assets/css/app.css" type="text/css">
    <!-- end::custom styles -->

</head>
<body class="bg-white h-100-vh p-t-0">

<c:if test="${not empty cookie.aname}">
    <c:redirect url="/login/toCookieLogin">
        <c:param name="aname" value="${cookie.aname.value}"></c:param>
        <c:param name="apass" value="${cookie.apass.value}"></c:param>
    </c:redirect>
</c:if>

<div class="p-b-50 d-block d-lg-none"></div>

<div class="container h-100-vh">
    <div class="row align-items-md-center h-100-vh">
        <div class="col-lg-6 d-none d-lg-block">
            <img class="img-fluid" src="${APP_PATH}/assets/media/svg/login.svg" alt="...">
        </div>
        <div class="col-lg-4 offset-lg-1">
            <div class="d-flex align-items-center m-b-20">
                <img src="${APP_PATH}/assets/media/image/dark-logo.png" class="m-r-15" width="40px;" alt="">
                <h3 class="m-0">FANG</h3>
            </div>
            <p>欢迎登录.</p>
            <form id="loginForm" action="${APP_PATH}/login/toLogin">
                <div class="form-group mb-4">
                    <div id="captcha" style="position: relative; display: none; left: 20px;"></div>
                    <input type="text" class="form-control form-control-lg" id="aname" name="aname" autofocus placeholder="用户名">
                </div>
                <div class="form-group mb-4">
                    <input type="password" class="form-control form-control-lg" id="apass" name="apass" placeholder="密码">
                </div>
                <input type="submit" onclick="return toLogin()" value="登录" id="login" class="btn btn-primary btn-lg btn-block btn-uppercase mb-4"/>
                <div class="d-flex justify-content-between align-items-center mb-4">
                    <div class="custom-control custom-checkbox">
                        <input type="checkbox" class="custom-control-input" id="customCheck" name="cookie" value="cookie">
                        <label class="custom-control-label" for="customCheck">记住此账号</label>
                    </div>
                    <a href="#" class="auth-link text-black">忘记密码?</a>
                </div>
            </form>

        </div>
    </div>
</div>

<!-- begin::global scripts -->
<script src="${APP_PATH}/assets/vendors/bundle.js"></script>
<!-- end::global scripts -->

<!-- begin::custom scripts -->
<script src="${APP_PATH}/assets/js/app.js"></script>
<!-- end::custom scripts -->


<script type="text/javascript" src="${APP_PATH}/js/jigsaw.js"></script>
<script type="text/javascript">
    $(function () {
        if(${requestScope.msg == null?"false":"true"}){
            swal("${requestScope.msg}", {
                icon: "error"
            });
        }
    });

function toLogin() {
    if($("#aname").val() == '' || $("#apass").val() == ''){
        swal("请输入账号和密码！", {
            icon: "error"
        });
    }else{
        $("#aname,#apass").hide();
        $("#captcha").show();
    }
    return false;
}


    jigsaw.init(document.getElementById('captcha'), function () {
      $("#loginForm").submit();
    })
</script>
</body>
</html>
